package frontend.parser.syntaxtree;

import frontend.lexer.TKType;
import frontend.parser.syntaxtree.symbol.NonTerminalSymbol;
import frontend.parser.syntaxtree.symbol.TerminalSymbol;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class StmtNodeForPrintf extends StmtNode {
    public String StringConst;
    public List<ExpNode> exps = new ArrayList<>();
    public int printfLineNum = -1;

    @Override
    public void walk(Consumer<TerminalSymbol> terConsumer, Consumer<NonTerminalSymbol> nonTerConsumer) {
        terConsumer.accept(new TerminalSymbol(TKType.PRINTFTK));
        terConsumer.accept(new TerminalSymbol(TKType.LPARENT));

        terConsumer.accept(new TerminalSymbol(TKType.STRCON, StringConst));

//        for (var exp : exps) {
//            terConsumer.accept(new TerminalSymbol(TKType.COMMA));
//            exp.walk(terConsumer, nonTerConsumer);
//        }
        exps.forEach(exp -> {
            terConsumer.accept(new TerminalSymbol(TKType.COMMA));
            exp.walk(terConsumer, nonTerConsumer);
        });
        terConsumer.accept(new TerminalSymbol(TKType.RPARENT));
        terConsumer.accept(new TerminalSymbol(TKType.SEMICN));

        nonTerConsumer.accept(new NonTerminalSymbol(this));
    }
}
